package com.tgjs.sphoto.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.blankj.utilcode.util.BarUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.Gson;
import com.gyf.barlibrary.ImmersionBar;
import com.tgjs.sphoto.constant.ConstantValues;
import com.tgjs.sphoto.constant.RequestWhatI;
import com.tgjs.sphoto.request.Api;


import butterknife.ButterKnife;

/**
 * 作者：wzh
 * 创建时间：2018/5/22 13:15
 * NrcCommunity
 */

public abstract class BaseActivity extends AppCompatActivity implements RequestWhatI {


    protected Gson mGson;
    protected int statusBarHeight;
    protected Api mApi;
    private Context mContext;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContentView());
        ButterKnife.bind(this);
        ImmersionBar.with(this).init();
        mContext=this;
        mGson = new Gson();
        initViews();
    }

    protected abstract int getContentView();
    protected abstract void initViews();

    /**
     * activity跳转（无参数）
     *
     * @param className
     */
    public void startActivity(Class<?> className) {
        Intent intent = new Intent(mContext, className);
        startActivity(intent);
    }


    /**
     * activity跳转（有参数）
     *
     * @param className
     */
    public void startActivity(Class<?> className, Bundle bundle) {
        Intent intent = new Intent(mContext, className);
        intent.putExtras(bundle);
        startActivity(intent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ImmersionBar.with(this).destroy();
    }
}
